<div id="content">
<?php
if (!$download) {
    ?>
    <div class="DivTable">
            <?= form_open("", "method=get") ?>
        <table>
            <tr>
                <td>Tahun/Bulan</td>
                <td>:</td>
                <td>
                        <?= form_dropdown("tahun", $list_tahun, $tahun, "id=tahun") . "&nbsp;/&nbsp;" .
                                form_dropdown("bulan", $list_bulan, $bulan, "id=bulan")
                                ?>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>
                        <?= form_submit(array("name" => "btnSubmit"), "Cari") ?>
                        <?= form_close() ?>
                        <?= form_open("", "method=get") ?>
                    <input type="hidden" name="tahun" value="<?=$tahun?>">
                    <input type="hidden" name="bulan" value="<?=$bulan?>">
                    <input type="hidden" name="excel" value="download">
                        <?= form_submit(array("name" => "btnSubmit"), "Download ke Excel") ?>
                        <?= form_close() ?>
                </td>
            </tr>
        </table>        
    </div>
    <br/>
        <?php
    } else {
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename="rekap_absensi_'.$bulan."-".$tahun. '.xls"');
        header('Pragma: no-cache');
        header('Expires: 0');
    }
    ?>
    <div class="DivTable">        
        <center><h1>LAPORAN REKAP ABSENSI (<?=$bulan."-".$tahun?>)</h1></center><br>        
        <table class="GridTable" style="width: 100%;">
            <thead>
                <tr>
                    <th>NIK</th>
                    <th>Nama</th>
                    <th>Normal</th>
                    <th>Terlambat</th>
                    <th>Sakit</th>
                    <th>Ijin</th>
                    <th>Cuti</th>
                    <th>Mangkir</th>
                    <th>Dinas</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach($result as $row) {
                    ?>
                <tr>
                    <td><?=$row["nik"]?></td>
                    <td><?=$row["nama"]?></td>
                    <td><?=$row["NORMAL"]?></td>
                    <td><?=$row["TERLAMBAT"]?></td>
                    <td><?=$row["SAKIT"]?></td>
                    <td><?=$row["IJIN"]?></td>
                    <td><?=$row["CUTI"]?></td>
                    <td><?=$row["MANGKIR"]?></td>
                    <td><?=$row["DINAS"]?></td>                    
                <tr>
                        <?php
                    }
                    ?>
            </tbody>
        </table>
    </div>
</div>